package Day21;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ClientDemo01 {
    public static void main(String[] args) throws IOException {
        //搭建服务器
        ServerSocket server = new ServerSocket(65535);//端口号自己定
        System.out.println("服务器启动完毕");
        //等待客户端连接
        while (true) {
            Socket socket = server.accept();
            new Thread(){
                @Override
                public void run() {
                    try {
                        InputStream is = socket.getInputStream();
                        OutputStream os = socket.getOutputStream();
                        System.out.println("一个客户端连接了");
                        socket.getOutputStream();
                        PrintStream ps = new PrintStream(os);
                        ps.println("滴~~打卡");
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }.start();
        }







//        System.out.println("一个客户端连接了");
//        OutputStream os = socket.getOutputStream();
//        PrintStream ps = new PrintStream(os);
//        ps.println("滴~~打卡");
////
////
//        InputStream is = socket.getInputStream();
//        BufferedReader br = new BufferedReader(new InputStreamReader(is));
//        String text = br.readLine();
//        System.out.println("收到消息：" + text);
//        System.out.println("打卡结束");

    }
}
